/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import com.nokia.mid.ui.gestures.GestureEvent;
import com.nokia.mid.ui.gestures.GestureInteractiveZone;
import com.nokia.mid.ui.gestures.GestureListener;

/**
 *
 * @author tuokor
 */
public class TouchGameView extends Game implements GestureListener{

    private long lasttimestamp;
    public void gestureAction(Object container, GestureInteractiveZone gestureZone, GestureEvent gestureEvent) {

        switch (gestureEvent.getType()) {
            case GestureInteractiveZone.GESTURE_DRAG:
                long current = System.currentTimeMillis();
                if (lasttimestamp == 0) {
                    lasttimestamp = current;
                }
                if ((current - lasttimestamp) > 20) {
                    handleDrag(gestureEvent);
                    lasttimestamp = current;
                }
                break;
            case GestureInteractiveZone.GESTURE_TAP:
                int x = gestureEvent.getStartX();
                int y = gestureEvent.getStartY();
                if(x <= 60 && y <= 30) {
                    Main.getInstance().SMenu();
                    
                }
                break;
        }
    }

    private void handleDrag(GestureEvent event) {
        int start_x = event.getStartX();
        int Xdistance = event.getDragDistanceX();
        int result = start_x + Xdistance;
        Xdistance = Math.abs(Xdistance);
       
    }

}
